package com.restaurant.serviceimpl;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.restaurant.domain.Menumodifires;
import com.restaurant.service.MenumodifiresService;

public class MenumodifiresServiceImpl implements MenumodifiresService {

   private HibernateTemplate hibernateTemplate;

   @Autowired
   public void setSessionFactory(SessionFactory sessionFactory){
       this.hibernateTemplate = new HibernateTemplate(sessionFactory);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menumodifires addOrModify( Menumodifires objMenumodifires ) {
       return ( Menumodifires ) hibernateTemplate.merge( objMenumodifires );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menumodifires deleteRecord( Menumodifires objMenumodifires ) {
       hibernateTemplate.delete( objMenumodifires );
       return objMenumodifires;
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menumodifires modifyRecord( Menumodifires objMenumodifires ) {
       return ( Menumodifires ) hibernateTemplate.merge( objMenumodifires );
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Menumodifires> loadAll() {
       return (List<Menumodifires>)hibernateTemplate.findByNamedQuery( "Menumodifires.findAll");
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menumodifires loadByPrimaryKey( Long primaryKey ) {
       return (Menumodifires) hibernateTemplate.get( Menumodifires.class, primaryKey );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menumodifires deleteByPrimaryKey( Long primaryKey ) {
       return deleteRecord(loadByPrimaryKey(primaryKey));
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Menumodifires> loadByHql(String query) {
       return ( List<Menumodifires> ) hibernateTemplate.find( query );
   }
}